package WaiBao;

import java.util.Arrays;

public class ZhangXing {
    public static void main(String[] args) {
        String[] name = {"何静婷(班长)", "李天(副班长)", "小李(学习委员)", "李天东(纪律委员)", "张天栋", "李霞", "张紧着", "荔湾", "王晓红", "李大红", "李刚", "王晓天",
                "张浩天", "凌泽楷", "王阳明", "杜甫", "杜牧", "杜海涛", "度天理", "王铮", "王政", "王海", "王兴云", "王晓峰", "王天明", "王新安", "王子文", "王凯",
                "王哈哈", "张鑫(学生)"};//考生本人:张鑫(学生)
        int[] age = {20, 21, 20, 18, 20, 20, 20, 20, 20, 18, 20, 20, 21, 20, 20, 21, 18, 18, 18, 18, 19, 19, 20, 20, 20, 20, 20, 20, 21, 19};//考生本人年龄:19

        double[] ketting1 = {77, 60, 85, 92, 90, 74, 78, 75, 81, 91, 91, 87, 83, 79, 65, 64, 89, 95, 86, 88, 92, 91, 95, 65, 75, 74, 95, 84, 87, 96};
        double[] ketting2 = {88, 77, 75, 86, 85, 67, 77, 64, 73, 84, 82, 77, 76, 85, 85, 65, 76, 69, 76, 98, 72, 71, 95, 87, 77, 88, 84, 74, 88, 95};
        double[] ketting3 = {64, 61, 84, 85, 75, 64, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 66, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 84, 95};


        double cai1 ;//代表每个学生的总分
        double cai2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            cai1  =ketting1[i] + ketting2[i] + ketting3[i];
//            cai2 = (cai1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + cai1);
//            System.out.println(name[i] + "的平均分为:"+ cai2);
//        }


        double pi1 = 0, pi2 = 0;
        double[] gg = new double[30];
//        for (int i = 0; i < 30; i++) {
//            pi1=ketting1[i] + ketting2[i] + ketting3[i];
//            pi2 = (pi1* 1.0) / 3;
//            gg[i] = pi2;
//        }
//
//        for (int i = 0; i < gg.length - 1; i++) {
//            for (int j = 0; j < gg.length - i - 1; j++) {
//                if (gg[j] <gg[j + 1]) {
//                    double tep = gg[j];
//                    gg[j] = gg[j + 1];
//                    gg[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println( gg[i]);
//        }



        double qiang1 = 0, qiang2 = 0,qiang3 = 0;//计算每门课的平均分
        double dada1 = 0, dada2 = 0, dada3 = 0;//计算每门课标准差
        double tun1 = 0, tun2 = 0, tun3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < ketting1.length; i++) {
            he +=ketting1[i];
        }
        qiang1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" + qiang1);
        double Sum = 0;
        for (int i = 0; i < ketting2.length; i++) {
            Sum +=ketting2[i];
        }
        qiang2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + qiang2);
        double sum = 0;
        for (int i = 0; i <ketting3.length; i++) {
            sum +=ketting3[i];
        }
        qiang3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + qiang3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <ketting1.length; i++) {
            c1 += (ketting1[i] - qiang1) * (ketting1[i] - qiang1);
        }
        dada1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + dada1);
        for (int i = 0; i < ketting2.length; i++) {
            c2 += (ketting2[i] - qiang2) * (ketting2[i] -qiang2);
        }
        dada2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +dada2);

        for (int i = 0; i <ketting3.length; i++) {
            c3 += (ketting3[i] -qiang3) * (ketting3[i] - qiang3);
        }
        dada3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" + dada3);
////////////
        Arrays.sort(ketting1);
        Arrays.sort(ketting2);
        Arrays.sort(ketting3);
        tun1 = (ketting1[15] +ketting2[14]) * 1.0 / 2;
        tun2 = (ketting2[15] +ketting2[14]) * 1.0 / 2;
        tun3 = (ketting3[15] +ketting3[14]) * 1.0 / 2;
        System.out.println("农业设施及环境调控的中位数为:" + tun1);
        System.out.println("农业设施设计与制造的中位数为:" + tun2);
        System.out.println("园艺植物设施栽培学的中位数为:" + tun3);




    }
}
